
<!DOCTYPE html>

<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />

    <title>Extending pysmb For Other Frameworks &#8212; pysmb 1.2.8 documentation</title>
    <link rel="stylesheet" type="text/css" href="_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="_static/sphinxdoc.css" />
    <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
    <script src="_static/jquery.js"></script>
    <script src="_static/underscore.js"></script>
    <script src="_static/_sphinx_javascript_frameworks_compat.js"></script>
    <script src="_static/doctools.js"></script>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="Upgrading from older pysmb versions" href="upgrading.html" />
    <link rel="prev" title="Security Descriptors" href="api/smb_security_descriptors.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="upgrading.html" title="Upgrading from older pysmb versions"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="api/smb_security_descriptors.html" title="Security Descriptors"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">pysmb 1.2.8 documentation</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">Extending pysmb For Other Frameworks</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="extending-pysmb-for-other-frameworks">
<h1>Extending pysmb For Other Frameworks<a class="headerlink" href="#extending-pysmb-for-other-frameworks" title="Permalink to this heading">¶</a></h1>
<p>This page briefly describes the steps involved in extending pysmb for other frameworks.</p>
<p>In general, you need to take care of the SMB TCP connection setup, i.e. finding the IP address of the remote server and connect to the SMB/CIFS service.
Then you need to read/write synchronously or asynchronously from and to the SMB socket. And you need to handle post-authentication callback methods, and from these methods,
initiate file operations with the remote SMB/CIFS server.</p>
<dl>
<dt>Now the above steps in more technical details:</dt><dd><ol class="arabic simple">
<li><p>Create a new class which subclasses the <em>smb.base.SMB</em> class. Most often, the connection setup will be part of the <em>__init__</em> method.</p></li>
<li><p>Override the <em>write(self, data)</em> method to provide an implementation which will write <em>data</em> to the socket.</p></li>
<li><p>Write your own loop handling method to read data from the socket. Once data have been read, call <em>feedData</em> method with the parameter.
The <em>feedData</em> method has its own internal buffer, so it can accept incomplete NetBIOS session packet data.</p></li>
<li><p>Override</p></li>
</ol>
<blockquote>
<div><ul class="simple">
<li><p><em>onAuthOK</em> method to include your own operations to perform when authentication is successful. You can initiate file operations in this method.</p></li>
<li><p><em>onAuthFailed</em> method to include your own processing on what to do when authentication fails. You can report this as an error, or to try a different NTLM authentication algorithm (<em>use_ntlm_v2</em> parameter in the constructor).</p></li>
<li><p><em>onNMBSessionFailed</em> method to include your own processing on what to do when pysmb fails to setup the NetBIOS session with the remote server. Usually, this is due to a wrong <em>remote_name</em> parameter in the constructor.</p></li>
</ul>
</div></blockquote>
</dd>
</dl>
</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <div>
    <h4>Previous topic</h4>
    <p class="topless"><a href="api/smb_security_descriptors.html"
                          title="previous chapter">Security Descriptors</a></p>
  </div>
  <div>
    <h4>Next topic</h4>
    <p class="topless"><a href="upgrading.html"
                          title="next chapter">Upgrading from older pysmb versions</a></p>
  </div>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="_sources/extending.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>document.getElementById('searchbox').style.display = "block"</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="upgrading.html" title="Upgrading from older pysmb versions"
             >next</a> |</li>
        <li class="right" >
          <a href="api/smb_security_descriptors.html" title="Security Descriptors"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">pysmb 1.2.8 documentation</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">Extending pysmb For Other Frameworks</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2001-2021, Michael Teo https://miketeo.net/.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 5.0.1.
    </div>
  </body>
</html>